use cosmwasm_std::{HumanAddr, StdResult, Storage};
use cosmwasm_storage::ReadonlySingleton;
use cosmwasm_storage::Singleton;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

pub const REWARDTOKENMAXDECIAML: u64 = 1_000;
static CONFIG_KEY: &[u8] = b"config";

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct ConfigInfo {
    pub owner: HumanAddr,
}

pub fn store_config<S: Storage>(storage: &mut S, data: &ConfigInfo) -> StdResult<()> {
    Singleton::new(storage, CONFIG_KEY).save(data)
}

pub fn read_config<S: Storage>(storage: &S) -> StdResult<ConfigInfo> {
    ReadonlySingleton::new(storage, CONFIG_KEY).load()
}
